﻿using System;
using Glue.Internals.Nulls;
using Xunit;

namespace GlueTests
{
    public class NullExtensionsTest
    {
        [Fact]
        public void Should_report_if_it_is_null()
        {
            String aString = null;
            Assert.True(aString.IsNull());
        }

        [Fact]
        public void Should_create_Maybe_from_null()
        {
            String aString = null;
            var maybe = aString.AsMaybe();
            Assert.False(maybe.HasValue());
        }

        [Fact]
        public void Should_create_Maybe_from_value()
        {
            String aString = "a string";
            var maybe = NullExtensions.AsMaybe(aString);
            Assert.True(maybe.HasValue());
            Assert.Same(aString, maybe.GetValue());
        }
    }

}
